import 'package:flutter/material.dart';

class SizeFit {
  static double? physicalWidth;
  static double? physicalHeight;
  static double? screenWidth;
  static double? screenHeight;
  static double? dpr;
  static double? statusHeight;

  static double? rpx;
  static double? px;

  static void initialize(BuildContext context,{double standardSize = 750}) {
    // 物理宽高
    physicalWidth = View.of(context).physicalSize.width;
    physicalHeight = View.of(context).physicalSize.height;
    dpr = View.of(context).devicePixelRatio;
    // 屏幕宽高
    screenWidth = MediaQuery.of(context).size.width;
    screenHeight = MediaQuery.of(context).size.height;
    // 状态栏
    statusHeight = MediaQuery.of(context).padding.top;

    rpx = screenWidth! / standardSize;
    px = screenWidth! / standardSize * 2;
  }

  static double setRpx(double size) {
    return rpx! * size;
  }

  static double setPx(double size) {
    return px! * size;
  }
}
